#ifndef _Ape_EventModel_EventArgs_h
#define _Ape_EventModel_EventArgs_h

#include <Ape/Object.h>
#include <Ape/Collections/Array.h>

namespace Ape {
	namespace EventModel {
		class EventArgs : public Object {
			TYPE_NAME ("Ape::EventModel::EventArgs")
		private:
			Object* m_Sender;
			bool m_Cancel;
			
			Ape::Collections::Array<Object*> m_Args;
			Ape::Collections::Array<bool> m_ArgsAutoDeletion;
		public:
			//EventArgs(Object* sender);
			EventArgs (Object* sender, int argsCount = 0);
			virtual ~EventArgs();
			
			void Cancel();
			bool Cancelled() const;
			
			//Ape::Collections::Array<Object*>& Args();
			
			void setArg (size_t iPos, Object* oVal, bool bAutoDelete = false);
			
			template <class Arg_t>
			const Arg_t& A (size_t iPos) const;
			size_t get_ArgsCount() const;
			
			Object* get_Sender() const;
		};
		
		template <class Arg_t>
		const Arg_t& EventArgs::A (size_t iPos) const {
			return *reinterpret_cast<Arg_t*> (m_Args[iPos]);
		}
	}
}

#endif // _Ape_EventModel_EventArgs_h
